home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17962 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: prodigy.com!usenet
  2. From: AXHM04A@prodigy.com (Brian Cahill)
  3. Newsgroups: comp.lang.c++
  4. Subject: HELP!  Programming SOUND with TCWIN
  5. Date: 18 Apr 1996 03:39:13 GMT
  6. Organization: Prodigy Services Company  1-800-PRODIGY
  7. Distribution: world
  8. Message-ID: <4l4dh1$27bq@usenetw1.news.prodigy.com>
  9. NNTP-Posting-Host: innugap7-int.news.prodigy.com
  10. X-Newsreader: Version 1.2
  11.  
  12. I'm trying to program my SoundBlaster 16 ASP for the first time.  I have 
  13. the Lamothe book on game programming, and it's got some source code 
  14. examples written, I believe, in Microsoft C.  However, I'm using Turbo 
  15. C++ for Windows (TCWIN), and I'm having some difficulty using the _FP_SEG 
  16. and _FP_OFF functions.  Here are their declarations:
  17.  
  18.    unsigned _FP_SEG (void far *p);
  19.    unsigned _FP_OFF (void far *p);
  20.  
  21. The CTVOICE.DRV driver has to be loaded at a segment boundary (offset=0), 
  22. or it acts funky.  This is accomplished in the Lamothe book like this:
  23.  
  24.    int driver_handle;
  25.    unsigned segment,num_para,bytes_read;
  26.  
  27.    // open the driver
  28.  
  29.    _dos_open("CT-VOICE.DRV", O_RDONLY, &driver_handle);
  30.  
  31.    // allocate the memory
  32.  
  33.    num_para = 1 + (filelength(driver_handle))/16;
  34.  
  35.    _dos_allocmem(num_para,&segment);
  36.  
  37.    // point driver pointer to data area
  38.  
  39.    _FP_SEG(driver_ptr) = segment;       // PROBLEM STATEMENT
  40.    _FP_OFF(driver_ptr) = 0;                   // PROBLEM STATEMENT
  41.  
  42.    // load in the driver code
  43.  
  44.    data_ptr = driver_ptr;
  45.  
  46.    do
  47.     {
  48.     _dos_read(driver_handle,data_ptr, 0x4000, &bytes_read);
  49.     data_ptr += bytes_read;
  50.  
  51.     } while(bytes_read==0x4000);
  52.  
  53.    // close the file
  54.  
  55.    _dos_close(driver_handle);
  56.  
  57. The two lines annotated with "PROBLEM STATEMENT" above are the ones that 
  58. I'm having difficulty with.  The TCWIN compiler gives me an "LVALUE 
  59. REQUIRED" error on both lines.  I've got no problem using _FP_SEG and 
  60. _FP_OFF on the right hand side of statements, but on the right hand side 
  61. they just don't compile for me with TCWIN.
  62.  
  63. Any and all help/advice will be greatly appreciated!
  64. Thanks in advance,
  65. Brian
  66. <bcahill@prodigy.com>
  67.  
  68.